import { createRouter, createWebHistory } from 'vue-router'
import Home from '../views/Home.vue'

const routes = [
  {  //首页， 也就是根路由
    path: '/',     //路由
    name: 'Home',    //给path取个别名
    component: Home   //地址
  },
  {  //生活追忆
    path:'/lifebeen',
    name:'LifeBeen',
    component:() =>import('../views/LifeBeen.vue'),
  },
  {   //Blog留言
    path:'/blogleave',
    name:'BlogLeave',
    component:()=> import('../views/BlogLeave.vue'),
  },
  {  //关于我
    path: '/aboutme',
    name: 'AboutMe',
    redirect:'/aboutme/aboutauthor',  //只要一点击关于我模块，就会显示关于作者模块
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutMe.vue'),
    // 子路由  访问路径  /aboutme/aboutauthot
    children:[
      { //关于作者模块
        path:'aboutauthor',
        name:'AboutAuthor',
        component:()=>import('../components/AboutAuthor.vue'),
      },
      {
        //  留言联系模块
        path:'messagecontact',
        name:'MessageContact',
        component:()=>import('../components/MessageContact.vue'),
      }
    ]
  },
  {   //关于友链
    path:'/personBlog',
    name:'PersonBlog',
    component:()=> import('../views/PersonBlog'),
  },
  {   // 文章详情页模块 
    path:'/article/:id',   //动态路由
    name:'ArticleMDetails',
    component:()=>import('../views/ArticleDetails.vue'),
  },
  {   // 后台管理
    path:'/admin',
    name:'Admin',
    component:()=>import('../views/Admin.vue')
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
